package gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Welcome extends JPanel{
	private JLabel lbl_Welcome;
	private JButton btn_Next;
	private JRadioButton rdbtn_User;
	private JRadioButton rdbtn_Admin;
	private JTextField textField_ID;
	private JLabel lbl_ID;
	private JLabel lbl_PIN;
	private JPasswordField passwordField_PIN;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	
	public Welcome() {
		setLayout(null);
		
		lbl_Welcome = new JLabel("Welcome to the ATM of Gruppe 7!");
		lbl_Welcome.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		lbl_Welcome.setBounds(99, 21, 275, 20);
		add(lbl_Welcome);
		
		btn_Next = new JButton("Login!");
		btn_Next.setBounds(283, 239, 104, 37);
		add(btn_Next);
		
		rdbtn_User = new JRadioButton("Login as User");
		buttonGroup.add(rdbtn_User);
		rdbtn_User.setFont(new Font("SansSerif", Font.PLAIN, 14));
		rdbtn_User.setBounds(99, 90, 113, 27);
		add(rdbtn_User);
		
		rdbtn_Admin = new JRadioButton("Login as Admin");
		buttonGroup.add(rdbtn_Admin);
		rdbtn_Admin.setFont(new Font("SansSerif", Font.PLAIN, 14));
		rdbtn_Admin.setBounds(264, 90, 123, 27);
		add(rdbtn_Admin);
		
		textField_ID = new JTextField();
		textField_ID.setBounds(155, 150, 130, 20);
		add(textField_ID);
		textField_ID.setColumns(10);
		
		lbl_ID = new JLabel("ID");
		lbl_ID.setFont(new Font("SansSerif", Font.PLAIN, 14));
		lbl_ID.setBounds(99, 153, 46, 14);
		add(lbl_ID);
		
		lbl_PIN = new JLabel("PIN");
		lbl_PIN.setFont(new Font("SansSerif", Font.PLAIN, 14));
		lbl_PIN.setBounds(99, 211, 46, 14);
		add(lbl_PIN);
		
		passwordField_PIN = new JPasswordField();
		passwordField_PIN.setBounds(155, 208, 130, 20);
		add(passwordField_PIN);
	
	}
	
	public void addActionListener(ActionListener event) {
		btn_Next.addActionListener(event);
	}

	public void NoAcc(){
		textField_ID.setText("");
	}
	
	public void NoPin(){
		passwordField_PIN.setText("");
	}
	
	public int getAcc(){
		return Integer.parseInt(textField_ID.getText().trim()); // skal hentes fra data
	}
	
	public int getPin(){
		char[] t = passwordField_PIN.getPassword();
		return Integer.parseInt(new String(t)); // det samme her  */
	}
		
	
	}

